﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HROReporting.Infrastructure.Authentication;
using HROReporting.Services.Interfaces;
using HROReporting.Infrastructure.CookieStorage;
using System.Web.Mvc;
using HROReporting.Controllers.ViewModels.DocentMap;
using HROReporting.Services.Messaging.SchoolLocatieService;
using HROReporting.Services.Messaging.DocentService;

namespace HROReporting.Controllers.Controllers
{
    public class DocentMapController : BaseController
    {
        private readonly IFormsAuthentication _formsAuthentication;
        private readonly IDocentService _docentService;
        private readonly ISchoolLocatieService _schoolLocatieService;

        public DocentMapController(ICookieStorageService cookieStorageService,
                                   IFormsAuthentication formsAuthentication,
                                   IDocentService docentService,
                                   ISchoolLocatieService schoolLocatieService)
            : base (cookieStorageService)
        {
            _formsAuthentication = formsAuthentication;
            _docentService = docentService;
            _schoolLocatieService = schoolLocatieService;
        }

        // Schoollocaties ophalen
        public ActionResult Index()
        {
            DocentMapIndexView docentMapIndexView = new DocentMapIndexView();

            GetAllLocatiesResponse response = _schoolLocatieService.GetAllSchoolLocaties();

            docentMapIndexView.SchoolLocaties = response.SchoolLocatieViews;

            return View(docentMapIndexView);
        }

        // Specifieke docent
        public ActionResult Details(string id)
        {
            DocentMapDetailView view = new DocentMapDetailView();

            GetDocentByRequest request = new GetDocentByRequest();
            request.DocentCode = id;

            GetDocentByResponse response = new GetDocentByResponse();
            response.Docent = _docentService.GetDocentByDocentCode(request).Docent;

            view.Docent = response.Docent;

            return View(view);
        }
    }
}
